CC=@gcc
CPPFLAGS+=-D_FILE_OFFSET_BITS=64 -D'VERSION="0.0.9"'
CFLAGS+=-pedantic -Waggregate-return -Wall -Warray-bounds -Wbad-function-cast -Wcast-align -Wcast-qual -Wdeclaration-after-statement -Wdisabled-optimization -Wextra -Wfloat-equal -Wformat=2 -Wframe-larger-than=1024 -Winit-self -Winline -Wlarger-than=1024 -Wlogical-op -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wredundant-decls -Wshadow -Wstrict-aliasing -Wstrict-overflow=5 -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wunsafe-loop-optimizations -Wwrite-strings -std=c99 -fhosted -fvisibility=hidden -fstrict-overflow -funsafe-loop-optimizations -g -pipe
TARGET_ARCH=-march=native

depdir=.dep

bins=main

sub_objs=sub.o sub_optdebug.o sub_ls.o sub_cut.o sub_shift.o

all: $(bins)

main: main.o err.o selector.o str.o opt.o flv.o flvio.o scan.o $(sub_objs)

ifneq ($(MAKECMDGOALS),clean)
-include $(patsubst %.c,$(depdir)/%.d,$(wildcard *.c))
endif

$(depdir)/%.d: %.c
	@mkdir -p $(depdir)
	@$(CC) -MM $(CPPFLAGS) $< | sed 's#\($*\)\.o[ :]*#\1.o $@: #g' > $@

.PHONY: clean strip

clean:
	$(RM) -r *.o $(depdir) $(bins)

strip:
	strip -R .comment $(objs)
